<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<h1>JavaScript Example 15</h1>
<br>
Working with Arrays.
<br>
<hr>
<br>

<!-- SCRIPT STARTS HERE -->

<script type="text/javascript">
	// function to print an array
	function printArray(anArray) {
		for (var i=0;i<anArray.length;i++) {
			if (i>0) document.write(",");
			document.write(anArray[i]);			
		}
		document.writeln("<p>");
		
	}	

	// declare an array
	var arr = new Array(5);
	printArray(arr)

	// set some values and print again - note that we declared only 5 slots
	// but that a value for the index 10: arrays can grow dynamically!
	arr[0] = 0;
	arr[1] = 1;
	arr[2] = 2;
	arr[10] = 10;
	printArray(arr);		
	
</script>


<!-- SCRIPT ENDS HERE -->

</body>
</html>
